/**
 * 1、写一个名为Account的类模拟账户。该类的属性和方法如下图所示。
 * 该类包括的属性：账号id，余额balance，年利率annualInterestRate；
 * 包含的方法：访问器方法（getter和setter方法），返回月利率的方法getMonthlyInterest()，取款方法withdraw()，存款方法deposit()。
 *


 */
public class Account {
    private  int id;
    private double balance;
    private double annuallnterestRate;   //年利率

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getAnnuallnterestRate() {
        return annuallnterestRate;
    }

    public void setAnnuallnterestRate(double annuallnterestRate) {
        this.annuallnterestRate = annuallnterestRate;
    }

    public double getMonthlyInterest(){
        return annuallnterestRate / 12;
    }

    public void withdraw(double amount){
        if (amount > 0 && amount <= balance){
            balance -= amount;
            System.out.println("成功取出" + amount);
        }else{
            System.out.println("余额不足,您的账户余额为" + balance);
        }

    }

    public void deposit(double amount){
        if (amount > 0){
            balance += amount;
            System.out.println("成功存入" + amount);
        }

    }

    //构造
    public Account() {
    }

    public Account(int id, double balance, double annuallnterestRate) {
        this.id = id;
        this.balance = balance;
        this.annuallnterestRate = annuallnterestRate;
    }
}
